package com.hospital.doctor.doctorc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hospital.doctor.doctorc.dao.MedicineDao;
import com.hospital.doctor.doctorc.entity.DrugEntity;
import com.hospital.doctor.doctorc.entity.MedicineEntity;
import com.hospital.doctor.doctorc.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: MedicineServiceimpl
 * @description：
 * @author：TanKai
 * @date：2021/9/17 16:18
 * @versions：v1.0
 */
@Service
public class MedicineServiceimpl implements MedicineService {

    @Autowired
    private MedicineDao medicineDao;

    @Override
    public PageInfo<MedicineEntity> MedicinePaging(Integer doctorId, String username, Integer pageNum) {
        PageHelper.startPage(pageNum, 5);
        List<MedicineEntity> entityList = medicineDao.MedicineRecordSelect(doctorId, username, pageNum);
        PageInfo<MedicineEntity> pageInfo = new PageInfo<>(entityList);
        return pageInfo;
    }

    @Override
    public boolean pwdSelectOK(String doctorid, String doctorpwd, String doctorpwdxin, String doctorPwdOk_pwd) {
        int i = medicineDao.pwdSelectOK(doctorid, doctorpwd);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Boolean delete(int id) {
        Integer delete = medicineDao.delete(id);
        if (delete > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Boolean update(MedicineEntity m) {
        Integer update = medicineDao.update(m);
        if (update > 0) {
            return true;
        }
        return false;
    }

    @Override
    public List<DrugEntity> list() {
        return medicineDao.list();
    }

}
